//
//  GetSearchSpotTask.m
//  ZooNgonDoiOS
//
//  Created by Anh Jun Linh Tinh on 7/4/12.
//  Copyright (c) 2012 Personal. All rights reserved.
//

#import "GetSearchSpotTask.h"

@implementation GetSearchSpotTask

-(id)initWithParams:(NSString *)name lon:(NSString *)lon lat:(NSString *)lat{
    self = [self initWithParams:name limit:0 lon:lon lat:lat];
    return self;
}

-(id)initWithParams:(NSString *)name limit:(int)limit lon:(NSString *)lon lat:(NSString *)lat{
    self = [super init];
    if (self) {
        _name = name;
        _limit = limit;
        _lon = lon;
        _lat = lat;
    }
    return self;
}

-(void)doExecute{
    NSMutableArray *arrKeys = [[NSMutableArray alloc] init];
    NSMutableArray *arrValues = [[NSMutableArray alloc] init];
    
    [arrKeys addObject:@"long"];
    [arrKeys addObject:@"lat"];
    [arrValues addObject:_lon];
    [arrValues addObject:_lat];
    
    if(_limit > 0){
        [arrKeys addObject:@"limit"];
        NSString* strLimit = [NSString stringWithFormat:@"%i", _limit];
        [arrValues addObject:strLimit];
    }
    NSDictionary *params = [NSDictionary dictionaryWithObjects:arrValues forKeys:arrKeys];
    [[RKObjectManager sharedManager].client get:@"/spot/search" queryParameters:params delegate:self];
    
}
-(void)request:(RKRequest *)request didLoadResponse:(RKResponse *)response{
    
}
-(void)request:(RKRequest *)request didFailLoadWithError:(NSError *)error{
    
}
@end
